<script setup lang="ts">
// 定义组件属性接口，使用TypeScript类型声明增强代码可读性
interface BlogPostProps {
  title: string
  content: string
}

// 使用defineProps接收父组件传递的属性
defineProps<BlogPostProps>()
// 使用 defineEmits 定义组件事件
defineEmits(['enlarge-text'])
</script>

<template>
  <!-- 博文卡片容器 -->
  <div class="blog-post">
    <!-- 博文标题 -->
    <h3 class="blog-title">{{ title }}</h3>

    <!-- 分割线 -->
    <div class="divider"></div>

    <!-- 博文内容 -->
    <div class="blog-content">
      <p>{{ content }}</p>
    </div>

    <!-- 底部装饰 -->
    <div class="blog-footer">
      <button @click="$emit('enlarge-text')">Enlarge text</button>
      <div class="dot"></div>
    </div>
  </div>
  <slot />
</template>

<style scoped>
/* 博文卡片主容器 */
.blog-post {
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

/* 卡片悬停效果 */
.blog-post:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

/* 标题样式 */
.blog-title {
  font-size: 1.5em;
  font-weight: 600;
  color: #2c3e50;
  margin: 0 0 16px 0;
  position: relative;
  display: inline-block;
}

/* 标题下划线装饰 */
.blog-title::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 60px;
  height: 3px;
  background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
  border-radius: 2px;
}

/* 分割线样式 */
.divider {
  height: 1px;
  background: linear-gradient(90deg, rgba(79, 172, 254, 0) 0%, rgba(79, 172, 254, 0.5) 50%, rgba(79, 172, 254, 0) 100%);
  margin: 8px 0 20px;
}

/* 内容区域样式 */
.blog-content {
  font-size: 1.1em;
  line-height: 1.7;
  color: #34495e;
  text-align: justify;
  margin-bottom: 20px;
}

/* 内容段落样式 */
.blog-content p {
  margin: 0;
  padding: 16px;
  background-color: rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  border-left: 4px solid #4facfe;
}

/* 底部装饰区域 */
.blog-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

/* 底部装饰点 */
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(45deg, #4facfe 0%, #00f2fe 100%);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .blog-post {
    padding: 18px;
    margin-bottom: 16px;
  }

  .blog-title {
    font-size: 1.3em;
  }

  .blog-content {
    font-size: 1em;
  }

  .blog-content p {
    padding: 12px;
  }
}
</style>
